package org.jeeasy.common.core.domain.vo;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.jeeasy.common.core.enums.IDictEnum;

import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;

/**
 * @author AlpsDDJ
 * @date 2021/8/13 14:45
 */
@Data
@Accessors(chain = true)
@NoArgsConstructor
public class DictVo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    //    @ApiModelProperty(value = "dictCode", notes = "字典值")
    private Object dictCode;
    //    @ApiModelProperty(value = "dictName", notes = "字典名称")
    private String dictName;

    private String color;

    public DictVo(IDictEnum<?> dictEnum) {
        if (Objects.nonNull(dictEnum)) {
            this.dictCode = dictEnum.getValue();
            this.dictName = dictEnum.getText();
            this.color = dictEnum.getColor();
        }
    }

    public DictVo(Object dictCode, String dictName) {
        this.dictCode = dictCode;
        this.dictName = dictName;
    }

    public DictVo(Object dictCode, String dictName, String color) {
        this.dictCode = dictCode;
        this.dictName = dictName;
        this.color = color;
    }

    //    @JsonIgnore
//    private Integer leaf;
//
//    @JsonGetter("isLeaf")
//    public Boolean isLeaf(){
//        return BooleanEnum.yes(leaf);
//    }
}
